<template>
	<div class="login">
		<div class="bax">
			<div class="log">
				<el-page-header @back="back">
				</el-page-header>
				<form>
					<input type="password" v-model="user.newPwd" placeholder="输入原来的密码" />
					<input type="password" v-model="user.oldPwd" placeholder="密码" />
					<input type="password" v-model="user.oldPwd2" placeholder="确定密码" />
				</form>
				<div class="but">
					<button @click="login">登录</button>
					<!-- <button @click="back">返回</button> -->
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import {
		mapActions,
		mapState
	} from 'vuex';


	export default {
		name: 'Login', //登录
		components: {
		},
		data() {
			return {
				user: {}, //登录用户信息
			}
		},
		methods: {
		
			login() {
	
				 if(this.user.oldPwd==this.user.oldPwd2){}
				this.$axios.post('/api/user//updatePwd', this.user, {
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded;charset=utf8'
					}
				}, ).then((res) => {
					if (res.status == 200) {
						console.log(res.data.data.token);
						this.selToken(res.data.data.token)
						this.$axios.get('/api/user/info').then((res2) => {
							console.log(res2);
							if (res2.status == 200) {
								console.log(res2.data.data);
								this.selWord({
									account: res2.data.data.account,
									name: res2.data.data.name,
									role: res2.data.data.role,
									img: res2.data.data.img
								})
								this.$message({
									message: "登录成功",
									type: "success"
								})
								this.$router.push('/mobile/myinfo');
							}
						}).catch((error1) => {
							console.log(error1);
						})
					}
				}).catch((error2) => {
					console.log(error2);
				})
			},
			back() {
				this.$router.go(-1);
			}
		},
	}
</script>

<style scoped>
	.login .bax {
		background-color: #bcc883;
		width: 100%;
		height: 100%;
		position: absolute;
		position: fixed;
		bottom: 0;
		background-size: 100% 100%;

	}

	.login {
		width: 100%;
		height: 100%;
		color: white;
	}

	.login .log form {
		margin: auto;
		margin-top: 40%;
		display: flex;
		align-items: center;
		/* font-size: 200px; */
		/* padding: 5px 10px; */
		flex-direction: column;
		width: 100%;
		height: 13rem;


	}

	.login .log form input[type="text"],
	[type='password'] {
		width: 80%;
		height: 3rem;
		margin-top: 30px;
	}

	.login .log .but {
		display: flex;
		justify-content: center;
		align-items: center;
		
	}

	.login .log button {
		outline: none;
		border: none;
		width: 40%;
		height: 3rem;
		margin: 20px auto;
		background-image: linear-gradient(to right, #fffae8, #67c84c);

	}
</style>